<?php
namespace Admin\Controller;

class LogisticsController extends BaseController{
    public function index(){
    	$Logistics = D('Logistics');
    	$object = $Logistics->all($this->page($Logistics->total()));
    	$this->assign('All',$object);
    	$this->display();
    }
    
    public function add(){
    	if (IS_POST){
    		$Logistics = D('Logistics');
    		$object = $Logistics->insert();
    		if (is_numeric($object)){
    			$object>0 ? $this->success(U(CONTROLLER_NAME.'/index'),'物流添加成功！') : $this->failed('物流添加失败！');
    		}else{
    			$this->failed($object);
    		}
    	}
    	$this->display();
    }
    
    public function multi(){
    	if (IS_POST){
    		$Logistics = D('Logistics');
    		$object = $Logistics->multi();
    		is_numeric($object) ? $this->success(U(CONTROLLER_NAME.'/index'),'物流批量添加成功！') : $this->failed($object);
    	}
    	$this->display();
    }
    
    public function update(){
		if (I('get.id')){
			$Logistics = D('Logistics');
			if (IS_POST){
				$object = $Logistics->update();
				is_numeric($object) ? $this->success(U(CONTROLLER_NAME.'/index'),'物流修改成功！') : $this->failed($object);
			}
			$object = $Logistics->one();
			if (!$object) $this->failed('不存在此物流！');
			$this->assign('One',$object);
			$this->display();
		}else{
			$this->failed('非法操作！');
		}
    }
    
    public function delete(){
		if (I('get.id')){
			$Logistics = D('Logistics');
			if (IS_POST) $Logistics->remove() ? $this->success(I('post.prev'),'物流删除成功！') : $this->failed('物流删除失败！');
			if (!$Logistics->one()) $this->failed('不存在此物流！');
    		$this->confirm('您真的要删除这条数据么？');
    	}else{
    		$this->failed('非法操作！');
    	}
    }
}